package adsf.adminisadsf.gugedianzishichang.fragment;


import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import adsf.adminisadsf.gugedianzishichang.utils.LoadingPage;
import adsf.adminisadsf.gugedianzishichang.utils.UIUtils;

/**
 * Created by administrator on 17/5/9.
 */

public abstract class BaseFragment extends Fragment
{

    private LoadingPage mLoadingPage;

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {

        mLoadingPage = new LoadingPage(UIUtils.getContext()) {
            @Override
            public View onCreateSuccessView() {
                return BaseFragment.this.onCreateSuccessView();
            }

            @Override
            public ResultState onLoad() {
                return BaseFragment.this.onLoad();
            }
        };

        return mLoadingPage;

    }

    //让继承他的子类必须实现来个抽象类
    public abstract View onCreateSuccessView();

    public abstract LoadingPage.ResultState onLoad();

    public void loadData()
    {
        if (mLoadingPage != null)
        {
            mLoadingPage.loadData();
        }
    }

}
